#include<bits/stdc++.h>
using namespace std;

#define F(i,a,b) for(int i=a;i<=b;i++)
#define DF(i,a,b) for(int i=a;i>=b;i--)

int read(){int x=0,f=0;char ch=getchar();while(ch<48||ch>57){f|=(ch=='-');ch=getchar();}while(ch>=48&&ch<=57){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return f?-x:x;}
void write(int x){int _num=0;char ch[101];if(x<0){x=-x;putchar('-');}do{ch[++_num]=x%10+48;x/=10;}while(x>0);while(_num){putchar(ch[_num--]);}}

struct car
{
    int d,v,a;
    bool operator < (const car cj)const
    {
        return d<cj.d;
    }
}cz[100001],cf[100001];
int t,n,m,l,vmax,p[100001],ans,pmax,pmin,zpmax,anss,ansz;
int xd,xv,xa,zn,fn,fnum,fnear[100001];
bool zb[100001],fb[100001];

signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    t=read();
    while(t--)
    {
        n=read();m=read();l=read();vmax=read();
        ans=0;zn=fn=0;pmax=pmin=zpmax=anss=fnum=ansz=0;
        memset(fnear,0,sizeof(fnear));
        memset(zb,0,sizeof(zb));memset(fb,0,sizeof(fb));
        F(i,1,n)
        {
            xd=read(),xv=read(),xa=read();
            if(xa>=0)
            {
                cz[++zn].d=xd;cz[zn].v=xv;cz[zn].a=xa;
            }
            else
            {
                cf[++fn].d=xd;cf[fn].v=xv;cf[fn].a=xa;
            }
        }
        sort(cz+1,cz+zn+1);
        sort(cf+1,cf+fn+1);
        fnum=1;
        F(i,1,m)
        {
            p[i]=read();
            while(fnum<=fn&&cf[fnum].d<=p[i])
            {
                fnear[fnum++]=i;
            }
        }
        F(i,1,zn)
        {
            if(p[m]>=cz[i].d&&(p[m]-cz[i].d)*2*cz[i].a+cz[i].v*cz[i].v>vmax*vmax)
            {
                zb[i]=1;
                ansz++;
                ans++;
            }
        }
        F(i,1,fn)
        {
            if(fnear[i]!=0&&(p[fnear[i]]-cf[i].d)*2*cf[i].a+cf[i].v*cf[i].v>vmax*vmax)
            {
                fb[i]=1;
                ans++;
            }
        }
        write(ans);putchar(' ');
        ans=0;fnum=fn;
        while(fnum>0&&!fb[fnum])
        {
            fnum--;
        }
        if(fnum>0)
        {
            pmax=pmin=fnear[fnum];
            ans=1;
        }
        DF(i,fnum-1,1)
        {
            if(!fb[i])
            {
                continue;
            }
            if((p[pmin]-cf[i].d)*2*cf[i].a+cf[i].v*cf[i].v<=vmax*vmax)
            {
                pmin=fnear[i];
                ans++;
            }
        }
        if(ansz>0)
        {
            zpmax=1;
            F(i,1,zn)
            {
                if(!zb[i])
                {
                    continue;
                }
                while(p[zpmax]<cz[i].d||(p[zpmax]-cz[i].d)*2*cz[i].a+cz[i].v*cz[i].v<=vmax*vmax)
                {
                    zpmax++;
                }
            }
            if(zpmax>pmax)
            {
                pmin=pmax=zpmax;
                anss=1;fnum=fn;
                DF(i,fnum,1)
                {
                    if(!fb[i])
                    {
                        continue;
                    }
                    if((p[pmin]-cf[i].d)*2*cf[i].a+cf[i].v*cf[i].v<=vmax*vmax)
                    {
                        pmin=fnear[i];
                        anss++;
                    }
                }
                if(anss>ans)
                {
                    ans++;
                }
            }
        }
        write(m-ans);
        putchar('\n');
    }

    return 0;
}

